DATA_ROOT := ../../dataset
TMP_ROOT := ./tmp
train_enrollment_csv := $(DATA_ROOT)/enrollment_train.csv
test_enrollment_csv := $(DATA_ROOT)/test/enrollment_test.csv
train_log_csv := $(DATA_ROOT)/log_train.csv
test_log_csv := $(DATA_ROOT)/test/log_test.csv


# 用户加入某一课程时间  距离一个公共 时间
user_enter_course_day: train_user_enter_course_day test_user_enter_course_day
train_user_enter_course_day:  $(TMP_ROOT)/train_user_enter_course_day.feas
test_user_enter_course_day:  $(TMP_ROOT)/test_user_enter_course_day.feas
# 用户加入某一课程时间 中间已经学习的天数
user_enter_course_day_latest: train_user_enter_course_day_latest test_user_enter_course_day_latest
train_user_enter_course_day_latest:  $(TMP_ROOT)/train_user_enter_course_day_latest.feas
test_user_enter_course_day_latest:  $(TMP_ROOT)/test_user_enter_course_day_latest.feas
# 用户加入某一课程 学习的小时数
user_enter_course_hour_latest: train_user_enter_course_hour_latest test_user_enter_course_hour_latest
train_user_enter_course_hour_latest:  $(TMP_ROOT)/train_user_enter_course_hour_latest.feas
test_user_enter_course_hour_latest:  $(TMP_ROOT)/test_user_enter_course_hour_latest.feas
# 用户最近两次action 距离hours
user_latest_two_action_distance: train_user_latest_two_action_distance test_user_latest_two_action_distance
train_user_latest_two_action_distance: $(TMP_ROOT)/train_user_latest_two_action_distance
test_user_latest_two_action_distance: $(TMP_ROOT)/test_user_latest_two_action_distance
# 用户action间隔的mean min max std
user_course_action_distance_describe: train_user_course_action_distance_describe test_user_course_action_distance_describe
train_user_course_action_distance_describe: $(TMP_ROOT)/train_user_course_action_distance_describe
test_user_course_action_distance_describe: $(TMP_ROOT)/test_user_course_action_distance_describe
# 用户最近几天的操作次数 5天 10天
user_course_action_latest_count: train_user_course_action_latest_count.5 train_user_course_action_latest_count.10  \
							test_user_course_action_latest_count.5 test_user_course_action_latest_count.10  
train_user_course_action_latest_count.5: $(TMP_ROOT)/train_user_course_action_latest_count.5
test_user_course_action_latest_count.5: $(TMP_ROOT)/test_user_course_action_latest_count.5
train_user_course_action_latest_count.10: $(TMP_ROOT)/train_user_course_action_latest_count.10
test_user_course_action_latest_count.10: $(TMP_ROOT)/test_user_course_action_latest_count.10

# 用户学习某课程的action占所有学习action的比例
user_course_action_ratio_of_all: 
	./user_course_action_ratio_of_all.py $(train_log_csv) -1 $(TMP_ROOT)/train_user_course_action_ratio_of_all
	./user_course_action_ratio_of_all.py $(test_log_csv) -1 $(TMP_ROOT)/test_user_course_action_ratio_of_all
user_course_action_ratio_of_all.2: 
	./user_course_action_ratio_of_all.py $(train_log_csv) 2 $(TMP_ROOT)/train_user_course_action_ratio_of_all.2
	./user_course_action_ratio_of_all.py $(test_log_csv) 2 $(TMP_ROOT)/test_user_course_action_ratio_of_all.2
user_course_action_ratio_of_all.5: 
	./user_course_action_ratio_of_all.py $(train_log_csv) 5 $(TMP_ROOT)/train_user_course_action_ratio_of_all.5
	./user_course_action_ratio_of_all.py $(test_log_csv) 5 $(TMP_ROOT)/test_user_course_action_ratio_of_all.5
user_course_action_ratio_of_all.10: 
	./user_course_action_ratio_of_all.py $(train_log_csv) 10 $(TMP_ROOT)/train_user_course_action_ratio_of_all.10
	./user_course_action_ratio_of_all.py $(test_log_csv) 10 $(TMP_ROOT)/test_user_course_action_ratio_of_all.10

# 用户学习course 的 action 最近N天的时间
# 中间产物 方便后续的基于时间的统计
user_course_action_time: ./user_course_action_time.py
	./user_course_action_time.py -1 $(train_log_csv) 	 	$(TMP_ROOT)/train_user_course_action_time
	./user_course_action_time.py -1 $(test_log_csv) 	 	$(TMP_ROOT)/test_user_course_action_time

# 用户event基于weekday的统计
# TODO 在GBDT上效果不好
# count 差
# ratio 差
user_course_action_weekday: $(TMP_ROOT)/train_user_course_action_time $(TMP_ROOT)/test_user_course_action_time 
	#./user_course_action_weekday.py $(TMP_ROOT)/train_user_course_action_time overall $(TMP_ROOT)/train.user_course_action_weekday.overall
	#./user_course_action_weekday.py $(TMP_ROOT)/test_user_course_action_time overall $(TMP_ROOT)/test.user_course_action_weekday.overall
	make -f make.user_course_action_weekday user_course_action_weekday

user_course_event_ratio: $(TMP_ROOT)/train_user_course_action_time $(TMP_ROOT)/test_user_course_action_time 
	./user_course_event_ratio.py $(TMP_ROOT)/train_user_course_action_time
	./user_course_event_ratio.py $(TMP_ROOT)/test_user_course_action_time 

#events=overall problem video access wiki discussion nagivate page_close
events=overall problem video 
user_course_action_hour: $(TMP_ROOT)/train_user_course_action_time $(TMP_ROOT)/test_user_course_action_time 
	@set -x -e; \
	for event in $(events);  do \
		./user_course_action_hour.py $(TMP_ROOT)/train_user_course_action_time $${event} $(TMP_ROOT)/train_user_course_action_time.hour.$${event}&   \
	done; \
	wait; \
	for event in $(events);  do \
		./user_course_action_hour.py $(TMP_ROOT)/test_user_course_action_time $${event} $(TMP_ROOT)/test_user_course_action_time.hour.$${event}&   \
	done; \
	wait;








$(TMP_ROOT)/train_user_enter_course_day.feas: user_enter_course_day.py
	./user_enter_course_day.py $(train_log_csv) $(TMP_ROOT)/train_user_enter_course_day.feas

$(TMP_ROOT)/test_user_enter_course_day.feas: user_enter_course_day.py
	./user_enter_course_day.py $(test_log_csv) $(TMP_ROOT)/test_user_enter_course_day.feas


$(TMP_ROOT)/train_user_enter_course_day_latest.feas: user_enter_course_day_latest.py
	./user_enter_course_day_latest.py $(train_log_csv) $(TMP_ROOT)/train_user_enter_course_day_latest.feas

$(TMP_ROOT)/test_user_enter_course_day_latest.feas: user_enter_course_day_latest.py
	./user_enter_course_day_latest.py $(test_log_csv) $(TMP_ROOT)/test_user_enter_course_day_latest.feas

$(TMP_ROOT)/train_user_enter_course_hour_latest.feas: user_enter_course_hour_latest.py
	./user_enter_course_hour_latest.py $(train_log_csv) $(TMP_ROOT)/train_user_enter_course_hour_latest.feas

$(TMP_ROOT)/test_user_enter_course_hour_latest.feas: user_enter_course_hour_latest.py
	./user_enter_course_hour_latest.py $(test_log_csv) $(TMP_ROOT)/test_user_enter_course_hour_latest.feas

$(TMP_ROOT)/train_user_latest_two_action_distance: user_latest_two_action_distance.py
	./user_latest_two_action_distance.py $(train_log_csv) $(TMP_ROOT)/train_user_latest_two_action_distance

$(TMP_ROOT)/test_user_latest_two_action_distance: user_latest_two_action_distance.py
	./user_latest_two_action_distance.py $(test_log_csv) $(TMP_ROOT)/test_user_latest_two_action_distance

$(TMP_ROOT)/train_user_course_action_distance_describe: user_course_action_distance_describe.py
	./user_course_action_distance_describe.py $(train_log_csv) $(TMP_ROOT)/train_user_course_action_distance_describe

$(TMP_ROOT)/test_user_course_action_distance_describe: user_course_action_distance_describe.py
	./user_course_action_distance_describe.py $(test_log_csv) $(TMP_ROOT)/test_user_course_action_distance_describe

# 最近5天  10天操作数
$(TMP_ROOT)/train_user_course_action_latest_count.5: user_course_action_latest_count.py
	./user_course_action_latest_count.py 5 $(train_log_csv) $(TMP_ROOT)/train_user_course_action_latest_count.5
	
$(TMP_ROOT)/test_user_course_action_latest_count.5: user_course_action_latest_count.py
	./user_course_action_latest_count.py 5 $(test_log_csv) $(TMP_ROOT)/test_user_course_action_latest_count.5

$(TMP_ROOT)/train_user_course_action_latest_count.10: user_course_action_latest_count.py
	./user_course_action_latest_count.py 10 $(train_log_csv) $(TMP_ROOT)/train_user_course_action_latest_count.10
	
$(TMP_ROOT)/test_user_course_action_latest_count.10: user_course_action_latest_count.py
	./user_course_action_latest_count.py 10 $(test_log_csv) $(TMP_ROOT)/test_user_course_action_latest_count.10
